<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="hexinyang">
	<title>密码重置</title>
	<script language="javascript" type="text/javascript" src="../script/print.js"></script>
	<script language="javascript" src="../script/common.js" type="text/javascript"></script>	
	<script language="javascript" src="../script/card.js" type="text/javascript"></script>
	<script type="text/javascript">    
		//页面控件初始化
		var companyUserId;
		function load(){
			Eui.showNavigation();
			setPages(["readcardview","detview"]);
			CardMgnt.cardUser.show("userinfo");
		}
		
		function onReadCard(){
			try {
			/**
				getCard();
				try{appUnBlock();}catch(e){};		
				try{appLYUnBlock();}catch(e){};
			*/
				var data = CardMgnt.onFindCard("readCardForm","mgntQueryService.getCardUserInfo");
				if (!CardMgnt.checkInUseCard(data.card)) return;
				//if (!getNeedPin()) {showWarning("卡片没有启用卡密码！");return;}
				
				var cardUser = data.cardUser;
				$("resetpswdbtn").disabled = false;
				if (cardUser.type == CardUserType.DRIVER){
					$("radio1").style.display = "";
					checkTypeForm.checkType[0].checked = true;
					companyUserId = data.orgUser.id;
				}
				
				readCardForm.feeAmount.value = Format.fenToYuan(CardMgnt.getFee(Constants.ACCOUNT_FEE_RESET_PIN_CARD,data.cardType.id));
			
				CardMgnt.cardUser.showData("userinfo",data);
			}catch(e){
				showError(e.description);
			}
		}
		
		//重置密码
		function reloadPin(){
			try{
				var asn = readCardForm.asn.value;
				if(checkTypeForm.checkType[0].checked){
					if (!showQuestion("请插入主卡后点击确定核对客户身份，或取消返回。")) return;
					var msg = "当前主卡和预重置密码的副卡不匹配！"
					CardMgnt.checkMasterCard(companyUserId,msg);
					showInformation("主卡验证成功。<br>请插入卡片"+asn+"后，点击确定按钮！");
				}
				if (!CardMgnt.checkCardAsn(asn)) return;
				var confirmNewPin = Constants.DEFPIN;
				var pin = CardMgnt.inputCardPin("第一步：请持卡人输入新的密码");
				if (!pin) {onCancel();return;}
				var repeat = CardMgnt.inputCardPin("第二步：请重复输入新的密码");
				if (!repeat) {onCancel();return;};
				if (pin != repeat) {showWarning("两次输入的密码不一致！");return;}
				var pswdData = DWR.syncCall("cardMgntService.resetPassword",asn,pin);
				var re = evalCardReturn(cardCom.reLoadPin(hCard,pin,pswdData.mac.toUpperCase()));
				showInformation("密码重置完成！");		
				switchPage("detview");
				CardMgnt.showPrintView("detview","reset_pswd_bill",pswdData.logId,"重置密码凭证");
			}catch(e){
				showError(e.description);
				return ;
			}
		}	
		function onCancel(){
			switchPage("readcardview");
			readCardForm.reset();
			CardMgnt.cardUser.show("userinfo");
			$("resetpswdbtn").disabled = true;
			$("radio1").style.display = "none";
			checkTypeForm.checkType[1].checked = true;
		}
	</script>
	</head>
	<body onload="load()" onunload="releaseCard()">
		<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	
	<div id="readcardview">
		<div id="carddiv">
			<div class="form">
				<div class="formTitle">卡片信息</div>
				<form name="readCardForm" id="readCardForm" action="">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="label6">
							<tr>
								<td><label>卡&nbsp;&nbsp;&nbsp;&nbsp;号</label> <input type="text" name="asn" readonly class="readonly"></td>
								<td><label>手 续 费</label> <input type="text" name="feeAmount" readonly class="readonly"></td>
							</tr>
					</table>
				</form>
				<form name="checkTypeForm" id="checkTypeForm">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="label6">
						<tr>
							<td colspan=2><label>帐户校验</label><span id="radio1" style="display:none;"> <input type="radio" name="checkType" value="1">
								使用主卡</span> <input type="radio" name="checkType" value="2" checked>使用证件<span class=red>（请在读卡后核对客户帐户信息）</span></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		<div id="userinfo" class = "form">
		</div>
		<p>
			<button id="readCardBtn" onclick="onReadCard()">读 卡</button>
			<button id="resetpswdbtn" onclick="reloadPin()" disabled>重设密码</button>
			<button onclick="onCancel()">重 置</button>
		</p>
	</div>
	<div id="detview" style="display:none;">
	</div>
	</body>
</html>